const query = require("../db/connection");
const { params, route } = require("../router");
// 增
const addUserService = async (params)=>{
    const res = await query(`insert into user(username,password,nickname,age,phone) values("${params.username}","${params.password}","${params.nickname}","${params.age}","${params.phone}")`);
    return true
}
// 删
const deleteUserService =async (params)=>{
    const sql = `delete from user where (id="${params.id}")`;
    const res = await query(sql);
    return true
}
// 改
const updateUserService = async (params)=>{
    const sql = `update user set username="${params.username}",password = "${params.password}",nickname="${params.nickname}",age="${params.age}",phone="${params.phone}" where (id="${params.id}")`;
    const res = await query(sql);
    return true
}
// 查
const selectUserService = async (params)=>{
    const sql = `select * from user`;
    const res = await query(sql);
    return res
}


//抛出
module.exports = {
    addUserService,
    deleteUserService,
    updateUserService,
    selectUserService,
}